using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using SmartLink.Domain.Entity;
using SmartLink.Domain;

namespace SmartLink.IRepository
{
    public interface IRepository<T> where T : class, IEntity
    {
        dynamic Add(T entity, DbTransaction tran = null);
        bool AddAll(IEnumerable<T> entities);
        bool AddAll(IEnumerable<T> entities, DbTransaction tran = null);
        bool AddAllOutTran(IEnumerable<T> entities, DbTransaction tran = null);
        bool Delete(dynamic primaryKey, DbTransaction tran = null);
        bool DeleteLogic(dynamic primaryKey, DbTransaction tran = null);
        IEnumerable<T> ExecuteStoredProcedure(string StoredString, object param, DbTransaction tran);
        IEnumerable<T> ExecuteStoredProcedureWithParms(string StoredString, Dictionary<string, string> param, DbTransaction tran);
        IEnumerable<T> GetAll();
        IEnumerable<T> GetAll(bool containsLogicDeleted);
        void LockTableRead();
        void LockTableWrite();
        void UnLockTable();
        T GetById(dynamic id);
        bool Update(IEnumerable<T> entities);
        bool Update(T entity, DbTransaction tran = null);
        bool Delete(T entity, DbTransaction tran = null);

        DbTransaction TranCreate();
        void TranRollback(DbTransaction tran);
        void TranClose(DbTransaction tran);
        bool CheckExistByFiled(string fieldName, string filedValue, string tableName, bool hasDelFlag = false);
    }
}
